package cn.edu.nju.ws.sview.reasoning;

import cn.edu.nju.ws.sview.rdf.Resource;

/**
 * Constant
 * 
 * @author Gong Cheng
 * @author Gong Saisai
 */
public class Constant extends Term {
	private Resource resource = null;
    private int hash;
	/**
	 *constant
	 * 
	 * @param resource
	 *            constant RDF resource
	 */
	public Constant(Resource resource) {
		this.resource = resource;
	}

	/**
	 * 
	 * @return  constant RDF resource
	 */
	public Resource getResource() {
		return this.resource;
	}

	public boolean equals(Object constant) {
		if (constant instanceof Constant) {
			Constant constantO = (Constant) constant;
			if (this.resource.equals(constantO.resource)) {
				return true;
			}
		}
		return false;
	}

	public int hashCode() {
		int h = this.hash;
		if(h==0){
			h = this.resource.hashCode();
			this.hash = h;
		}
		 return h;
	}

	public String toString() {
		return this.resource.toString();
	}
}